'       N a m e :   M i c r o m e t r i c _ M e a s u r e _ 5 . t x t           9   S e p t e m b e r   2 0 1 9 
 
 '     A u t o r :   L e o n a r d o   D E   P A L O   P h . D . 
 
 '     S c o p e :   M e a s u r e   r e p e t i t i v i t y   a f t e r   z e r o   o p e r a t i o n   u s i n g   5 V   i n d u c t i v e 
 
 '                   s e n s o r .   S t e p p e r   m o t o r   N E M A   5 7 B Y G H 4 3 6 B . 
 
 ' 	 	     S t e p p e r   d r i v e r   W X M 2 5 6 
 
 ' 
 
 '   = = = = = = = = = =   V A R I A B L E   A S S I G N E M E N T   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '   v 1   t o   C o u n t   l o o p 
 
 '   v 2   b e   a s s i g n e d 
 
 '   v 3   b e   a s s i g n e d 
 
 '   v 4   b e   a s s i g n e d 
 
 '   v 5   b e   a s s i g n e d 
 
 '   v 6   b e   a s s i g n e d 
 
 '   v 7   b e   a s s i g n e d 
 
 '   v 8   b e   a s s i g n e d 
 
 '   v 9   b e   a s s i g n e d 
 
 
 
 '   = = = = = = = = = = =   M I C R O S T E P   H A R D W A R E   S E T   U P   W X M 2 5 6   = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '   M o t o r   M 2   c u r r e n t   2 5 0   m A 
 
 '   M i c r o s t e p   " A B C "     3 2 
 
 '   M i c r o s t e p   " A   C "   1 2 8 
 
 
 
 
 
 ' L o a d   x x x x x x . j p g 
 
 
 
 O p t i o n   S p e e d   9 
 
 B u t t o n   1   T e x t   H o m e M 2 ( Z ) 
 
 B u t t o n   2   T e x t   M o v e T o Z e r o 
 
 B u t t o n   3   T e x t   M o v e T o 1 0 
 
 B u t t o n   4   T e x t   M o v e 1 0 0 T i m e s 
 
 B u t t o n   5   T e x t   1 0 0 B _ s u b l o o p 
 
 
 
 B u t t o n   7   T e x t   H o m e 1 0 0 t i m e s 
 
 
 
 B u t t o n   8   T e x t   D i s a b l e M o t o r 
 
 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ H A L . e x e 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ S l o t V i e w e r . e x e 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ T e r m i n a l . e x e 
 
 ' L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ S l o t s T o S p e e c h . e x e 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ M i c r o V i d e o . e x e 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ S i g n a l S c o p e . e x e 
 
 
 
 s 2   =   " L o g T e s t . t x t " 
 
 v 3   =   9 9 
 
 K e y   P a g e u p 	 	 G o s u b   M o v e U p 
 
 K e y   P a g e d o w n 	 G o s u b   M o v e D o w n 
 
 
 
 G o s u b   D i s a b l e M o t o r 
 
 S t o p 
 
 
 
 
 
 '   = = = = = = = = = = = = = = =   H O M I N G   M O T O R   2   ( Z )   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   H o m e M 2 ( Z ) 
 
 	 G o s u b   E n a b l e M o t o r 
 
 	 L a b e l   H o m i n g _ M 2 _ 1 
 
 	 	 S l o t ( 5 )   =   S l o t ( 5 )   +   1 	 	 '   d i r e c t i o n   a n d   s p e e d   g o t o   s w i t c h 
 
 	 	 W a i t   S e c o n d s   0 . 0 5 	 	 	 '   p u l s e   u p   t i m e 
 
 	 	 I f   S l o t ( 2 1 )   >   5 0 0   	 	 	 '   l i m i t   s w i t c h 
 
 	 	 	 G o t o   H o m i n g _ M 2 _ 2 
 
 	 	 	 W a i t   S e c o n d s   0 . 3 	 	 '   s t a b i l i z e   b e f o r e   i n v e r s e   d i r e c t i o n 
 
 	 	 E n d I f 
 
 	 	 G o t o   H o m i n g _ M 2 _ 1 
 
 L a b e l   H o m i n g _ M 2 _ 2 
 
 	 S l o t ( 5 )   =   S l o t ( 5 )   -   0 . 0 1 	 	 '   d i r e c t i o n / s p e e d   r e t u r n   f r o m   s e n s o r 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 	 I f   S l o t   ( 2 1 )   <   5 0 0 	 	 	 	 '   l i m i t   s w i t c h 
 
 	 	 G o t o   H o m i n g _ M 2 _ 3 
 
 	 E n d I f 
 
 	 G o t o   H o m i n g _ M 2 _ 2 
 
 L a b e l   H o m i n g _ M 2 _ 3 
 
 	 W a i t   S e c o n d s   1 	 	 	 	 	 '   J U S T   T O   S E E   T H E   Z E R O   B Y   E Y E S 
 
 	 S l o t   5   =   R e s e t 	 	 	 	 	 '   R e s e t   t h e   s l o t   v a l u e 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 	 S l o t   5   =   0       	 	 	 	 	 '   d e c l a r e d   i n i t i a l   p o s i t i o n 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 	 S l o t   5   =   - 5   	 	 	 	 	 '   m o v e   d e s i d e r e   i n i t i a l   p o s i t i o n 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   T O   Z E R O   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   M o v e T o Z e r o 
 
 	 S l o t   5   =   0       	 	 	 	 	 '   d e c l a r e d   i n i t i a l   p o s i t i o n 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   T O   P O S I T I O N   1 0   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   M o v e T o 1 0 
 
 	 S l o t   5   =   - 1 0       	 	 	 	 	 '   d e c l a r e d   i n i t i a l   p o s i t i o n 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   1 0 0   T I M E S   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   M o v e 1 0 0 T i m e s 
 
 	 G o s u b   H o m e M 2 ( Z ) 
 
 	 v 1   =   0 
 
 	 L a b e l   L o o p 
 
 	 	 v 1   =   v 1   +   1 
 
 	 	 I f   v 1   >   1 0 0 
 
 	 	 	 G o s u b   H o m e M 2 ( Z ) 
 
 	 	 	 R e t u r n 
 
 	 	 E n d I f 
 
 	 	 ' 
 
 	 	 W a i t   S e c o n d s   1 
 
 	 	 S l o t   5   =   - 1 0 
 
 	 	 G o s u b   W a i t M 2 
 
 	 	 W a i t   S e c o n d s   0 . 8 
 
 	 	 S l o t   5   =   0 
 
 	 	 G o s u b   W a i t M 2 
 
 	 	 W a i t   S e c o n d s   0 . 8 
 
 	 	 v 2   =   S l o t ( 2 6 ) 
 
 	 	 S l o t   2 5   =   v 2 
 
 	 	 s 1   =   N o w 
 
 	 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 1 = "   +   v 1 
 
 	 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 2 = "   +   F o r m a t ( v 2 ,   " 0 . 0 0 0 " ) 
 
 	 	 P r i n t   s 1 
 
 	 	 S a v e   S t r i n g T o F i l e   s 1   s 2 
 
 	 G o t o   L o o p 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   1 0 0   T I M E S   W I T H   S U B L O O P   = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   1 0 0 B _ s u b l o o p 
 
 	 v 1   =   0 
 
 	 L a b e l   L o o p B 
 
 	 	 v 1   =   v 1   +   1 
 
 	 	 I f   v 1   >   1 0 0 
 
 	 	 	 G o s u b   H o m e M 2 ( Z ) 
 
 	 	 	 R e t u r n 
 
 	 	 E n d I f 
 
 	 	 ' 
 
 	 	 W a i t   S e c o n d s   1 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 G o s u b   M o v e M o t o r 1 m m 0 m m 
 
 	 	 ' 
 
 	 	 W a i t   S e c o n d s   0 . 8 
 
 	 	 v 2   =   S l o t ( 2 6 ) 
 
 	 	 S l o t   2 5   =   v 2 
 
 	 	 s 1   =   N o w 
 
 	 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 1 = "   +   v 1 
 
 	 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 2 = "   +   F o r m a t ( v 2 ,   " 0 . 0 0 0 " ) 
 
 	 	 P r i n t   s 1 
 
 	 	 S a v e   S t r i n g T o F i l e   s 1   s 2 
 
 	 G o t o   L o o p B 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e M o t o r 1 m m 0 m m 
 
 	 S l o t   5   =   - 1 
 
 	 G o s u b   W a i t M 2 
 
 	 S l o t   5   =   0 
 
 	 G o s u b   W a i t M 2 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   H O M I N G   M O T O R   2 ( Z )   M U L T I P L E   T I M E   = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   H o m e 1 0 0 t i m e s 
 
 	 G o s u b   E n a b l e M o t o r 
 
 	 v 1   =   0 
 
 	 L a b e l   L o o p M u l t i 
 
 	 	 v 1   =   v 1   +   1 
 
 	 	 I f   v 1   >   1 0 0 
 
 	 	 	 R e t u r n 
 
 	 	 E n d I f 
 
 	 	 L a b e l   H o m e M u l t i _ 1 
 
 	 	 	 S l o t ( 5 )   =   S l o t ( 5 )   +   0 . 1 	 '   d i r e c t i o n   a n d   s p e e d   g o t o   s w i t c h 
 
 	 	 	 W a i t   S e c o n d s   0 . 0 1 	 	 	 '   p u l s e   u p   t i m e 
 
 	 	 	 I f   S l o t ( 2 1 )   >   5 0 0   	 	 	 '   l i m i t   s w i t c h 
 
 	 	 	 	 G o t o   H o m e M u l t i _ 2 
 
 	 	 	 	 W a i t   S e c o n d s   0 . 3 	 	 '   s t a b i l i z e   b e f o r e   i n v e r s e   d i r e c t i o n 
 
 	 	 	 E n d I f 
 
 	 	 	 G o t o   H o m e M u l t i _ 1 
 
 L a b e l   H o m e M u l t i _ 2 
 
 	 S l o t ( 5 )   =   S l o t ( 5 )   -   0 . 0 0 5 	 	 '   d i r e c t i o n / s p e e d   r e t u r n   f r o m   s e n s o r 
 
 	 W a i t   S e c o n d s   0 . 0 1 
 
 	 I f   S l o t   ( 2 1 )   <   5 0 0 	 	 	 	 '   l i m i t   s w i t c h 
 
 	 	 G o t o   H o m e M u l t i _ 3 
 
 	 E n d I f 
 
 	 G o t o   H o m e M u l t i _ 2 
 
 L a b e l   H o m e M u l t i _ 3 
 
 	 W a i t   S e c o n d s   1 	 	 	 	 	 '   J U S T   T O   S E E   T H E   Z E R O   B Y   E Y E S 
 
 	 S l o t   5   =   R e s e t 	 	 	 	 	 '   R e s e t   t h e   s l o t   v a l u e 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 	 S l o t   5   =   0       	 	 	 	 	 '   d e c l a r e d   i n i t i a l   p o s i t i o n 
 
 	 G o s u b   W a i t M 2 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 	 v 3   =   S l o t ( 2 6 ) 
 
 	 S l o t   5   =   - 5   	 	 	 	 	 '   m o v e   d e s i d e r e   i n i t i a l   p o s i t i o n 
 
 	 G o s u b   W a i t M 2 
 
 	 W a i t   S e c o n d s   1 
 
 	 v 2   =   S l o t ( 2 6 ) 
 
 	 S l o t   2 5   =   v 2 
 
 	 s 1   =   N o w 
 
 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 1 = "   +   v 1 
 
 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 2 = "   +   F o r m a t ( v 2 ,   " 0 . 0 0 0 " ) 
 
 	 s 1   =   s 1   +   C h a r s ( "   " ,   4 )   +   " v 3 = "   +   F o r m a t ( V 3 ,   " 0 . 0 0 0 " ) 
 
 	 P r i n t   s 1 
 
 	 S a v e   S t r i n g T o F i l e   s 1   s 2 
 
 G o t o   L o o p M u l t i 
 
 R e t u r n 
 
 
 
 
 
 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - -   s u b r o u t i n e   a r e a   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 '   = = = = = = = = = = = = = = =   E N A B L E   /   D I S A B L E   M O T O R S   = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   E n a b l e M o t o r 
 
 	 S l o t   1 1   =   1 0 0 0 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 R e t u r n 
 
 
 
 L a b e l   D i s a b l e M o t o r 
 
 	 S l o t   1 1   =   1 0 0 0 	 	 	 	 	 ' i n v e r t e d   o n   t h e   H A L 
 
 	 W a i t   S e c o n d s   0 . 0 5 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   U P   A N D   D O W N   W I T H   K E Y B O A R D   = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   M o v e U p 
 
 	 G o s u b   E n a b l e M o t o r 	 	 	 ' B r e a k p o i n t 
 
 	 S l o t ( 5 )   =   S l o t ( 5 )   +   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e D o w n 
 
 	 G o s u b   E n a b l e M o t o r 	 	 	 ' B r e a k p o i n t 
 
 	 S l o t ( 5 )   =   S l o t ( 5 )   -   1 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = =   W   A   I   T       M   O   T   O   R     - 2 -   ( Z )   = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   W a i t M 2 
 
 '   - - - - - - - - - - - - - - - - - -   t h i s   W a i t   e n s u r e s   t h a t   t h e   m o t o r s   a r e   r e a l l y   s t a r t e d 
 
 	 W a i t   S e c o n d s   0 . 1 
 
 	 L a b e l   W a i t M 2 _ 2 
 
 	 	 I f   A b s ( S l o t ( 6 ) )   <   0 . 0 1 
 
 	 	 	 R e t u r n 
 
 	 	 E n d I f 
 
 	 	 W a i t   S e c o n d s   0 . 0 1 
 
 	 G o t o   W a i t M 2 _ 2 
 
 '   - - - - - - - - - - - - - - - - - -   t h i s   l i n e   i s   r e q u i r e d   t o   i n d e n t   c o r r e c t l y 
 
 G o t o   W a i t M 2 
 
 
 
 
 
 ' = = = = = =   D U M M Y   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 ' = = = = = =   T O   D O   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 ' = = = = = =   S E T   U P   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '   S t e p p e r D r i v e r   V 2   b o a r d   j u m p e r   s e t   u p   w i t h   W X M 0 0 6 : 
 
 '   M o t o r   M 2 ( Z ) :   ' 
 
 '   M i c r o s t e p   " A B C "     3 2 
 
 '   M i c r o s t e p   " A   C "   1 2 8 
 
 
 
 '   E N A B L E   s t e p p e r   m o t o r s : 
 
 '   f r o m   c e n t e r   t o   O N   =   a l w a y s   o n 
 
 '   f r o m   c e n t e r   t o   O u t 2   =   S W   c o n t r o l l e d 
 
 '   G e a r   r a t i o   f o r   M 0   a n d   M 1   1 : 4       S t e p   x   m m   =   8 0 0   x   3 6 0   /   3 6 0   =   5 9 . 5 5 6   ? ? ? ? ? ? ? ? ? ? ? 
 
 '   L e a d s c r e w :   4 m m   f o r   o n e   t u r n 
 
 '   I n d u c t i v e   s e n s o r :   B l u e = G N D     B r o w n = + 5 V D C     B l a c k = o u t p u t 
 
 
 
 
 
 ' W A T C H   N e w   w a t c h 
 
 ' W A T C H   N e w   w a t c h 
 
 ' W A T C H   v 1 
 
 ' W A T C H   s 1 
 
 ' W A T C H   N o w 
 
 ' W A T C H   P r i n t   N o w 
 
 ' W A T C H   N o w 
 
 